﻿@using LY.Interface
@using LY.Business.ServiceImpl
@using LY.Entity.Entities
@model LY.Entity.Entities.T_Project_EX
@{
    ViewBag.Title = Model.ProjectName;
    Layout = "~/Views/Shared/_Layout.cshtml";
    var begin = Convert.ToDateTime(Model.ProjectBeginDate);//开始时间
    var end = Convert.ToDateTime(Model.ProjectEndDate);//结束时间 
    var close = Convert.ToDateTime(Model.TenderTime);//满标时间
    var now = DateTime.Now;//当前时间
    var ts_cbd = end - begin;//筹标期限
    var ts_cb = end - now;//筹标倒计时时间差
    var ts_mb = end - close;//满标时间差
    var ts_sx = begin - now;//上线时间差
    var yrate = Model.AnnualisedRates * 100 + "<span class='s_k'>%<span>";
    var ayrate = Model.AddAnnualisedRates != 0 ? "+" + Model.AddAnnualisedRates * 100 + "<span class='s_k'>%<span>" : "";
}
<link href="~/Content/claims/css/toinvest.css" rel="stylesheet" />
<link href="~/Content/assets/plugins/tab/tab.css" rel="stylesheet" />
<link href="~/Content/assets/css/plugin/xjgridnew.css" rel="stylesheet" />
<script src="~/Content/assets/plugins/xjgrid/xjgrid.js"></script>
 

<div class="change_banner"></div>
<div class="line10"></div>
<div class="body">
    <div class="in_head">
        <div class="pro_title">@Model.ProjectName</div>
        <div class="pro_no">项目编号：@Model.ProjectNo</div>
    </div>
    <div class="in_con">
        <div class="c_01"></div>
        <div class="c_02">
            <div class="c_c">
                <div class="c_c_1">
                    <div class="k">年化收益率</div>
                    <div class="v"><span class="s_v">@Html.Raw(yrate)</span><span class="s_v">@Html.Raw(ayrate)</span></div>
                </div>
                <div class="c_c_2">
                    <div class="k">项目总额</div>
                    <div><span class="s_v">@Html.Raw(LY.Common.Utils.Tools.ConvertToMoney((long)Model.TotalLoan, true))</span></div>
                </div>
                <div class="c_c_3">
                    <div class="k">可投金额</div>
                    <div><span class="s_v">@Html.Raw(LY.Common.Utils.Tools.ConvertToMoney((long)ViewBag.AvaAmounts, true))</span></div>
                </div>
            </div>
            <div class="clear"></div>
            <div class="c_d">
                <div class="c_d_1"><span>开始时间</span>：@begin.ToString("yyyy-MM-dd HH:mm:ss")</div>
                <div class="c_d_2">项目期限：@Model.ProjectDurationStr</div>
                <div class="c_d_3">筹标时间：@(ts_cbd.Days)天</div>
                <div class="clear"></div>
            </div>
            <div class="c_e">
                <div>最小投资份数：1 份</div>
                <div>起息方式：@Model.RepaymentTypeStr</div>
                <div>最大投资份数：@(ViewBag.AvaAmounts / (decimal)Model.MinTenderAmount) 份</div>
                <div>起投金额：@Model.MinTenderAmount 元</div>
                <div class="clear"></div>
            </div>
        </div>
        <div class="c_03">
            <div class="c_03_con">

                <div class="c_c">剩余份数：<span class="v">@(ViewBag.AvaAmounts / (decimal)Model.MinTenderAmount)</span>份</div>
                <div class="c_c">
                    <div class="c_c_1">
                        <div class="bg">
                            <div class="progress" style="width:@ViewBag.RZJinDu%;"></div>
                        </div>
                    </div>
                    <div class="c_c_2">&nbsp;@ViewBag.RZJinDu%</div>

                </div>
                <div class="c_c">
                    投资金额：
                    <button id="jian">-</button>
                    <input class="txttend" id="money" type="text" maxlength="6" value="@Model.MinTenderAmount" />
                    <button id="jia">+</button>
                </div>
                <div class="c_c">
                    账户余额：
                @if (Session["CurrentUser"] == null)
                { 
                    <s><a href="/Login/Index"><b style="color: #ec303f">登录</b></a>后可见</s>
                }
                else
                {
                    <b class="balenceamt">@ViewBag.availableAmount</b><span>&nbsp;元</span><br />
                    <span>可用积分：<b class="balenceamt">@ViewBag.myScore</b></span>
                }
                </div>
                <div class="c_c">
                    @if (ViewBag.ProjectStatus == 1)
                    { 
                        <div class="btntend_end" style="background-color: rgb(207, 191, 191)">即将上线</div>
                    }
                    else if (ViewBag.ProjectStatus == 2)
                    { 
                        <div class="btntend" id="touzi">立即投资</div>
                    }
                    else if (ViewBag.ProjectStatus == 3)
                    {
                        <div class="btntend_end" style="background-color: rgb(207, 191, 191)">已经满标</div>
                    }
                    else if (ViewBag.ProjectStatus == 4)
                    {
                        <div class="btntend_end" style="background-color: rgb(207, 191, 191)">正在还款</div>
                    }
                    else if (ViewBag.ProjectStatus == 5)
                    {
                        <div class="btntend_end" style="background-color: rgb(207, 191, 191)">已经还款</div>
                    }
                    else
                    {
                        <div class="btntend_end" style="background-color: rgb(207, 191, 191)">筹标结束</div>
                    }
                </div>
            </div>
        </div>
    </div>

    <div style="margin-top: 10px; color: #808080; padding-left: 15px;">
        <div class="invest_b">
            <div class="invest_b_d">
                <p>
                    <span>筹标倒计时</span>：
                    <b id="day_show" style="font-size: 40px;">00</b>天
                <b id="hour_show" style="font-size: 35px;">00</b>小时
                <b id="minute_show" style="font-size: 30px;">00</b>分
                <b id="second_show" style="font-size: 20px;">00</b>秒
                </p>
            </div>
        </div>
    </div>
    <div class="clear"></div>

    <div class="in_boy">
        <div class="loan_extend_info">
            <div class="extend_nav_div">
                <ul id="tabs" class="clearfix">
                    <li><a href="#" name="#tab1">项目描述</a></li>
                    <li><a href="#" name="#tab2">风险控制</a></li>
                    <li><a href="#" name="#tab3">投资记录</a></li>
                    <li><a href="#" name="#tab4">相关文件</a></li>
                </ul>
            </div>
            <div id="content">
                <div id="tab1">
                    <span>
                        @Html.Raw(Model.ProjectDetail)
                    </span>
                </div>
                <div id="tab2">
                    <h2>风控审核报告</h2>
                    <div style="width: 100%; min-height: 150px">
                        @Html.Raw(Model.FKRemark)
                    </div>
                    <h2>风控审核流程</h2>
                    <div style="width: 100%; min-height: 150px">
                        @*@if ((bool)Model.VerifyIdCard)
                        {<img src="~/Content/assets/images/icons/star.png" />}
                        @if ((bool)Model.VerifyIsMarriage)
                        {<img src="~/Content/assets/images/icons/star.png" />}
                        @if ((bool)Model.VerifyCreditReporter)
                        {<img src="~/Content/assets/images/icons/star.png" />}
                        @if ((bool)Model.VerifyHouseProperty)
                        {<img src="~/Content/assets/images/icons/star.png" />}
                        @if ((bool)Model.VerifyRealEstateBook)
                        {<img src="~/Content/assets/images/icons/star.png" />}
                        @if ((bool)Model.VerifyBooklets)
                        {<img src="~/Content/assets/images/icons/star.png" />}
                        @if ((bool)Model.VerifyBankWater)
                        {<img src="~/Content/assets/images/icons/star.png" />}
                        @if ((bool)Model.VerifyOthers)
                        {<img src="~/Content/assets/images/icons/star.png" />}*@
                        <img src="~/Content/claims/claims_02.png" />
                    </div>
                </div>
                <div id="tab3">
                    <div style="width: 100%; min-height: 150px">
                        <div id="gridlist">
                            <img src="~/Content/assets/images/icons/star.png" />
                        </div>
                    </div>
                </div>
                <div id="tab4">
                    <div>
                        <div id="right_bottom" style="padding: 10px;">
                            @if (((List<T_Document_EX>)ViewData["doc"]).Count > 0)
                            {
                                foreach (var item in (List<T_Document_EX>)ViewData["doc"])
                                {
                                    if (item.Num == 1)
                                    {
                                <div style="float: left; padding: 30px;">
                                    <div style="margin-top: 10px; border: 1px solid #EEEEEE; background-color: white; height: 20px; font-size: 15px; padding: 10px; width: 280px;">@item.TypeName </div>
                                    <div id="cimg_@item.Type" style="width: 300px;border: 1px solid #EEEEEE;height: 280px;overflow:auto;background-color:white">
                                        <img src="@item.DocPath" class="upload-img1" width="120" height="120" style="margin:7px;cursor:pointer;"/>
                                    </div>
                                </div>
                                    }
                                    else
                                    {
                                <script>
                                    $("#cimg_@item.Type").append('<img src="@item.DocPath" class="upload-img1" width="120" height="120" style="margin:7px;cursor:pointer;"/>');
                                </script>
                                    }
                                }
                            }
                            else
                            {
                                <span>暂无相关文件</span>
                            }
                        </div>
                    </div>
                </div>
            </div>
        </div>
    </div>

</div>


<!--主容器-->
<div class="line10"></div>

<script src="~/Content/assets/plugins/tab/tab.js"></script>
<script src="~/Content/assets/plugins/countdown/daojishi.js"></script>
<script type="text/javascript">
    $(document).ready(function () {
        var options = [];
        options = {
            listUrl: '@Url.Action("GetInvestors", new { pid = Model.ID })'
        };

        var gridopt = {
            url: options.listUrl,
            colModel: [
                { display: '编号', name: 'ID', width: "10%", sortable: true, hide: true, align: 'left', iskey: true },
                {
                    display: '用户名', name: 'Name', width: "30%", sortable: true, align: 'left', process: function (value) {
                        return value.substr(0, 1) + "****" + value.substr(value.length - 1, value.length > 2 ? 1 : 0);
                    }
                },
                {
                    display: '投资金额', name: 'TenderAmt', width: "25%", sortable: true, align: 'left', process: function (value) {
                        if (value / 10000 >= 1) {
                            return value / 10000 + "(万元)";
                        } else {
                            return value + "(元)";
                        }
                    }
                },
                { display: '时间', name: 'CreateTime', width: "25%", sortable: true, align: 'left' },
                {
                    display: '状态', name: 'Status', width: "20%", sortable: true, align: 'center', process: function (value) {
                        if (value == 1) {
                            return "<span style='color:green'>投资成功</span>";
                        } else {
                            return "<span style='color:red'>投资失败/审核中</span>";
                        }
                    }
                }
            ],
            sortname: "ID",
            sortorder: "DESC",
            title: false,
            rp: 10,
            usepager: true,
            showcheckbox: false
        };
        var xjgrid = new xjGrid("gridlist", gridopt);


        function FormatTime(ss) {
            day = Math.floor(ss / (60 * 60 * 24));
            hour = Math.floor(ss / (60 * 60)) - (day * 24);
            minute = Math.floor(ss / 60) - (day * 24 * 60) - (hour * 60);
            second = Math.floor(ss) - (day * 24 * 60 * 60) - (hour * 60 * 60) - (minute * 60);
            if (day <= 9) day = '0' + day; if (hour <= 9) hour = '0' + hour;
            if (minute <= 9) minute = '0' + minute; if (second <= 9) second = '0' + second;
            if (day == 0) day = '00'; if (hour == 0) hour = '00';
            if (minute == 0) minute = '00'; if (second == 0) second = '00';
            $('#day_show').html(day); $('#hour_show').html(hour);
            $('#minute_show').html(minute); $('#second_show').html(second);
        }


        //满标状态时间初始化
        if (parseInt(@Model.TenderStatus) > 0) {
            FormatTime(@ts_mb.TotalSeconds);
        }
        if ('@ts_cb.TotalSeconds' > 0) {
            if (parseInt(@ViewBag.AvaAmounts) > 0) {//是否筹标已完成(满标)
                if ('@ts_sx.TotalSeconds' < 0) {
                    timer(@ts_cb.TotalSeconds)//计时器加载
                } else {
                    $(".invest_b_d p span").text("上线倒计时");
                    $(".c_d_1 span").text("上线时间");
                    timer(@ts_sx.TotalSeconds);//计时器加载
                }
            }
        }

        //进度条初始化
        $("#jindu").css("width",@ViewBag.RZJinDu+"%");

        //加减金额
        var m = parseInt($("#money").val());
        $("#jia").click(function () {
            if (m < parseInt(@ViewBag.AvaAmounts)) {
                m += parseInt(@Model.MinTenderAmount);
            }
            $("#money").val(m);
        });

        $("#jian").click(function () {
            if (m > parseInt(@Model.MinTenderAmount)) {
                m -= parseInt(@Model.MinTenderAmount);
            }
            $("#money").val(m);
        });

        //确认投资
        $("#touzi").click(function () {
            var money = $("#money").val();
            @* if ('@Model.IsNewProject' == 1 && '@ViewBag.IsNewProject' == "False") {
                $.dialog.alert("抱歉，该标仅对新手开放！<br/><br/>友情提示：新手标仅能投一次哦~");
                return;
            }*@

            if ('@ViewBag.IsLoading' == 0) {//是否已经登录
                $.dialog.tips("请先登录！", 1, "prompt.gif", function () {
                    location.href = "/Login/Index";
                });
            }
            else if (money == "") {//是否已经输入投标金额
                $.dialog.alert("您好，请输入投标金额！");
                return false;
            } else if (parseInt(money) > parseInt(@ViewBag.AvaAmounts)) {//是否超过可投金额
                $.dialog.alert("您好，该标目前可投金额为：" + '@LY.Common.Utils.Tools.ConvertToMoney((long)ViewBag.AvaAmounts, false)' + "！");
                return false;
            } else if (parseInt(money) < parseInt(@Model.MinTenderAmount)) {//是否低于起投金额
                $.dialog.alert("您好，该标的起投金额为：" + parseInt(@Model.MinTenderAmount) + "元。");
                return false;
            }
            else if (parseInt(money) % 10 != 0) {//是否是起投金额的整数倍
                $.dialog.alert("您好，金额请输入10的整数倍！");
                return false;
            }
            else if (parseInt(money) > parseInt(@ViewBag.availableAmount)) {//是否余额不足
                $.dialog.confirm("对不起，您的账户余额不足，是否前去个人中心充值？", function () {
                    location.href = "/Account/Recharge";
                });
                return false;
            }
            else {
                $.dialog({
                    id: 'frame',
                    lock: true,
                    fixed: true,
                    esc: false,
                    background: '#000', /* 背景色 */
                    opacity: 0.5,       /* 透明度 */
                    width: '1200px',
                    height: '800px',
                    drag: false,
                    resize: false,
                    content: 'url:/Claims/ConfirmInvest?id=@Model.ID&amount=' + $("#money").val(),
                    title: '确认投资'
                });
            }


@*            if (money != "") {//金额是否为空
                if (parseInt(money) <= parseInt(@ViewBag.AvaAmounts)) {//是否超过可投金额
                    if (parseInt(money) >= parseInt(@Model.MinTenderAmount)) {//是否低于起投金额
                        if (parseInt(money) % parseInt(@Model.MinTenderAmount) == 0) {//是否是起投金额的整数倍
                            if (parseInt(money) <= parseInt(@ViewBag.availableAmount)) {//是否余额不足 
                                $.dialog({
                                    id: 'frame',
                                    lock: true,
                                    fixed: true,
                                    esc: false,
                                    background: '#000', /* 背景色 */
                                    opacity: 0.5,       /* 透明度 */
                                    width: 950,
                                    height: 650,
                                    content: 'url:/Claims/ConfirmInvest?id=@Model.ID&amount=' + $("#money").val(),
                                    title: '确认投资'
                                });

                            } else {
                                if ('@ViewBag.availableAmount' == "") {//是否session已超时
                                    location.href = '/Login/Index';
                                } else {
                                    $.dialog.confirm("对不起，您的账户余额不足，是否前去个人中心充值？", function () {
                                        location.href = "/Account/Recharge";
                                    });
                                }
                            }
                        } else {
                            $.dialog.alert("您好，请输入起投金额的整数倍！");
                        }
                    } else {
                        $.dialog.alert("您好，该标的起投金额为：" + parseInt(@Model.MinTenderAmount) + "元");
                    }
                } else {
                    $.dialog.alert("您好，该标目前可投金额为：" + '@LY.Common.Utils.Tools.ConvertToMoney((long)ViewBag.AvaAmounts, false)');
                }
            } else {
                $.dialog.alert("您好，请输入投标金额！");
            }*@
        });

        $(".upload-img1").click(function () {
            if ('@Session["CurrentUser"]' != "") {
                var img = $(this).attr("src");
                var title = $(this).attr("title");
                $.dialog({
                    id: 'a15',
                    title: title,
                    lock: true,
                    content: '<img src="' + img + '" width="900"/>',
                    padding: 0
                });
            } else {
                $.dialog.tips("请先登录查看！", 1, "prompt.gif", function () {
                    location.href = "/Login/Index";
                });
            }
        });

    });
</script>
